#[derive(Parser)]
#[grammar = "lexer.pest"]
pub struct ExpressionParser;
#[derive(Debug, PartialEq)]
pub enum Token {
    Integer(i64),
    Operator(char),
}
pub fn tokenize(input: &str) -> Vec<Token> {
    let pair = ExpressionParser::parse(Rule::expr, input)
        .unwrap_or_else(|e| panic!("Parse error: {}", e))
        .next()
        .unwrap();
    pair.into_inner()
        .map(|p| match p.as_rule() {
            Rule::int => Token::Integer(p.as_str().parse().unwrap()),
            Rule::op => Token::Operator(p.as_str().chars().next().unwrap()),
            _ => unreachable!(),
        })
        .collect()
}
